# Contributor: Raed Rizqie <raed.rizqie@gmail.com>

_realname=notebook_shim
pkgbase=mingw-w64-python-jupyter_${_realname}
pkgname=${MINGW_PACKAGE_PREFIX}-python-jupyter_${_realname}
pkgver=0.2.2
pkgrel=1
pkgdesc='A shim layer for notebook traits and config (mingw-w64)'
arch=('any')
mingw_arch=('mingw32' 'mingw64' 'ucrt64' 'clang64' 'clang32' 'clangarm64')
url='https://jupyter.org/'
license=('spdx:BSD-3-Clause')
depends=(
    ${MINGW_PACKAGE_PREFIX}-python
    ${MINGW_PACKAGE_PREFIX}-python-jupyter_server
    ${MINGW_PACKAGE_PREFIX}-python-tomli)
makedepends=(
    ${MINGW_PACKAGE_PREFIX}-python-build
    ${MINGW_PACKAGE_PREFIX}-python-hatchling
    ${MINGW_PACKAGE_PREFIX}-python-installer)
source=("https://github.com/jupyter/notebook_shim/releases/download/v${pkgver}/${_realname}-${pkgver}.tar.gz")
sha256sums=('090e0baf9a5582ff59b607af523ca2db68ff216da0c69956b62cab2ef4fc9c3f')

prepare() {
  rm -rf python-build-${MSYSTEM} | true
  cp -r "${_realname}-${pkgver}" "python-build-${MSYSTEM}"
}

build() {
  msg "Python build for ${MSYSTEM}"
  cd "${srcdir}/python-build-${MSYSTEM}"
  ${MINGW_PREFIX}/bin/python -m build --wheel --skip-dependency-check --no-isolation
}

package() {
  cd "${srcdir}/python-build-${MSYSTEM}"
  MSYS2_ARG_CONV_EXCL="--prefix=" \
    ${MINGW_PREFIX}/bin/python -m installer --prefix=${MINGW_PREFIX} \
    --destdir="${pkgdir}" dist/*.whl

  install -Dm644 LICENSE "${pkgdir}${MINGW_PREFIX}/share/licenses/python-${_realname}/LICENSE"
}
